#include <bits/stdc++.h>

const int maxn=1005;

struct iostream
{
    const static int bufsiz=1500000;
    char inbuf[bufsiz],oubuf[bufsiz];
    int inp,oup;
    iostream():inp(bufsiz),oup(0){}
    inline iostream& operator >> (char &c){
        static int end=bufsiz;
        if(inp==end) end=fread(inbuf,1,bufsiz,stdin),inp=0;
        if(inp==end) c=EOF;
        else c=inbuf[inp++];
        return *this;
    }
    template <typename T> inline iostream& operator >> (T &r){
        char c;bool f=0;
        for(*this>>c;c>'9'||c<'0';*this>>c) if(c=='-') f=1;
        for(r=0;c<='9'&&c>='0';*this>>c) r=r*10+c-'0';
        if(f) r=-r;
        return *this;
    }
    inline iostream& operator << (const char &c){
        oubuf[oup++]=c;
        if(oup==bufsiz) fwrite(oubuf,bufsiz,1,stdout);
        return *this;
    }
    template <typename T> inline iostream& operator << (T r){
        static int sta[50];int len=0;
        if(r<0){*this<<'-';r=-r;}
        while(r) sta[len++]=r%10,r/=10;
        if(!len) *this<<'0';
        while(len--) *this<<(char)(sta[len]+'0');
        return *this;
    }
    ~iostream(){
        fwrite(oubuf,oup,1,stdout);
    }
};

iostream io;
int sta[maxn],belong[maxn],capital[maxn];
bool vis[maxn];
int g[maxn],v[maxn*2],nxt[maxn*2];
int head,cnt_block;
int b;

int dfs(int p){
    int size=0;
	vis[p]=1;
    sta[head++]=p;
	for(int j=g[p];j;j=nxt[j]){
		const int &tar=v[j];
		if(vis[tar]) continue;
		size+=dfs(tar);
		if(size>=b){
			cnt_block++;
			while(sta[--head]!=p) belong[sta[head]]=cnt_block;
            head++;
			capital[cnt_block]=p;
            size=0;
		}
	}
    return size+1;
}

int main(){
	int n;
	
	freopen("1086.in","r",stdin);
	freopen("1086.out","w",stdout);

	io>>n>>b;
	for(int i=1;i<n;i++){
		int x,y;
		io>>x>>y;
		v[i]=y;nxt[i]=g[x];g[x]=i;
		v[i+n]=x;nxt[i+n]=g[y];g[y]=i+n;
	}
	dfs(1);
	if(!cnt_block) io<<0<<'\n';
	else{
		while(head--) belong[sta[head]]=cnt_block;
		io<<cnt_block<<'\n';
		for(int i=1;i<=n;i++) io<<belong[i]<<' ';
		io<<'\n';
		for(int i=1;i<=cnt_block;i++) io<<capital[i]<<' ';
		io<<'\n';
	}

	return 0;
}